// 定义基类Vehicle
class Vehicle {
    private String make;
    private String model;

    // 构造函数
    public Vehicle(String make, String model) {
        this.make = make;
        this.model = model;
    }

    // 获取品牌
    public String getMake() {
        return make;
    }

    // 获取型号
    public String getModel() {
        return model;
    }

    // 虚方法drive
    public void drive() {
        System.out.println("驾驶车辆");
    }
}

// 定义子类Car，继承自Vehicle
class Car extends Vehicle {
    // 构造函数
    public Car(String make, String model) {
        super(make, model);
    }

    // 重写drive方法
    @Override
    public void drive() {
        System.out.println("驾驶汽车，舒适地在公路上行驶");
    }
}

// 定义子类Bike，继承自Vehicle
class Bike extends Vehicle {
    // 构造函数
    public Bike(String make, String model) {
        super(make, model);
    }

    // 重写drive方法
    @Override
    public void drive() {
        System.out.println("骑着自行车，享受自由的骑行");
    }
}

public class work421 {
    public static void main(String[] args) {
        // 声明Vehicle类型的数组
        Vehicle[] vehicles = new Vehicle[3];

        // 创建Car和Bike对象并存储在数组中
        vehicles[0] = new Car("Toyota", "Corolla");
        vehicles[1] = new Bike("Giant", "ATX 777");
        vehicles[2] = new Car("BMW", "3 Series");

        // 遍历数组，调用每个对象的drive方法
        for (Vehicle vehicle : vehicles) {
            vehicle.drive();
        }
    }
}
